package org.grottarossa.data;

import org.grottarossa.data.exception.DataSourceException;
import org.grottarossa.data.exception.QueryException;
import org.grottarossa.driver.ECMBuilderTemplate;
import org.grottarossa.template.data.pojo.utils.Container;

public abstract class Query
{
	protected String field = "";
	protected QueryFilter filter;
	protected String masterPropertyName="";
	protected String storagePropertyName="";
	protected final ECMBuilderTemplate m_builder;

	public Query(ECMBuilderTemplate builder)
	{
		this.m_builder = builder;

	}

	public enum ResultSetType
	{
		Table(0),
		List(1),
		KeyValue(2);

		ResultSetType(int value) {;}

		public boolean isTable() {
			return ( this.ordinal() == ResultSetType.Table.ordinal() ) ? true : false;
		}

		public boolean isList() {
			return ( this.ordinal() == ResultSetType.List.ordinal() ) ? true : false;
		}

		public boolean isKeyValue() {
			return ( this.ordinal() == ResultSetType.KeyValue.ordinal() ) ? true : false;
		}
	}

	public abstract Container execute(ResultSetType type) throws QueryException;

	public void setField(String field) {
		this.field = field;

	}
	public void setFilter(QueryFilter filter) {
		this.filter = filter;

	}
	public String getMasterPropertyName() {
		return this.masterPropertyName;
	}

	public void setMasterPropertyName(String value) {
		this.masterPropertyName = value;
	}

	public void setStoragePropertyName(String value) {
		 this.storagePropertyName=value;
	}
	public String getStoragePropertyName() {
		return this.storagePropertyName;
	}
}
